package leetcode.code1381;

public class CustomStack {

	int[] arr;
	int p;
	int maxSize;

	public CustomStack(int maxSize) {
		arr = new int[maxSize];
		p = 0;
		this.maxSize = maxSize;
	}

	public void push(int x) {
		if (p == maxSize) {
			return;
		}
		arr[p++] = x;
	}

	public int pop() {
		if (p == 0) {
			return -1;
		}
		return arr[--p];
	}

	public void increment(int k, int val) {
		for (int i = 0; i < Math.min(k, p); i++) {
			arr[i] += val;
		}
	}
}
